package com.yonyou.cyxdms.basedata.service.controller.basedata;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyxdms.basedata.service.dto.SearchProductDlrDTO;
import com.yonyou.cyxdms.basedata.service.dto.SearchVsProductDlrDTO;
import com.yonyou.cyxdms.basedata.service.service.basedata.ProductGroupService;
import com.yonyou.cyxdms.basedata.service.vo.TreeVO;
import com.yonyou.cyxdms.basedata.service.vo.VsProductDlrVO;
import io.micrometer.core.instrument.search.Search;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "动力 车系 树状结构", tags = {"动力 车系 树状结构"})
@RestController
@RequestMapping("/productGroup")
public class ProductGroupController {

    @Autowired
    private ProductGroupService productGroupService;

    @ApiOperation(value = "根据id获取返利规则", notes = "根据id获取返利规则", httpMethod = "GET")
    @GetMapping("/tree")
    public List<TreeVO> tree(@RequestParam(value = "optionCode",required = false)String optionCode,
                             @RequestParam(value = "productCode",required = false)String productCode){
       return productGroupService.tree(optionCode,productCode);
    }

    @ApiOperation(value = "获取车辆批售车型信息学", notes = "获取车辆批售车型信息学", httpMethod = "GET")
    @PostMapping("/queryList")
    public IPage<VsProductDlrVO> queryList(@RequestBody SearchVsProductDlrDTO dto){
        Page<VsProductDlrVO> page = new Page(dto.getCurrentPage(), dto.getPageSize());
        page.setRecords(productGroupService.queryListByDlr(page,dto));
        return page;
    }

    @ApiOperation(value = "获取车辆批售车型信息学", notes = "获取车辆批售车型信息学", httpMethod = "GET")
    @GetMapping("/selectByProductCode")
    public VsProductDlrVO selectByProductCode(@RequestParam(value = "productCode",required = false)String productCode,
                                              @RequestParam(value = "dealerCode",required = false) String dealerCode,
                                              @RequestParam(value = "powerType",required = false)Integer powerType,
                                              @RequestParam(value = "appId",required = false)String appId){
        return productGroupService.selectByProductCode(productCode,dealerCode,powerType,appId);
    }




}
